"""
共享模块
包含数据模型、数据库连接、工具函数等
"""

from .models import db, User, Task, TaskExecution, SystemLog, TaskStatus, TaskType, ScriptFolder, UserScript, NotificationConfig
from .database import init_db, create_admin_user, get_db_stats, cleanup_old_logs
from .utils import (
    generate_execution_id, generate_task_hash, validate_cron_expression,
    get_next_run_time, parse_environment_variables, parse_dependencies,
    format_duration, sanitize_log_output, is_task_overdue, get_system_info,
    create_response
)
from .service_client import (
    ServiceClient, SchedulerClient, ExecutorClient, ServiceRegistry,
    get_service_registry, get_scheduler_client, get_executor_client
)
from .timezone_utils import (
    get_current_time, get_utc_time, convert_to_local_time, convert_to_utc,
    naive_to_aware, aware_to_naive, format_datetime, utcnow, now,
    DEFAULT_TIMEZONE, UTC_TIMEZONE
)
# 为了向后兼容，创建别名
timezone_now = now

__all__ = [
    # 数据模型
    'db', 'User', 'Task', 'TaskExecution', 'SystemLog', 'TaskStatus', 'TaskType', 'ScriptFolder', 'UserScript', 'NotificationConfig',
    # 数据库函数
    'init_db', 'create_admin_user', 'get_db_stats', 'cleanup_old_logs',
    # 工具函数
    'generate_execution_id', 'generate_task_hash', 'validate_cron_expression',
    'get_next_run_time', 'parse_environment_variables', 'parse_dependencies',
    'format_duration', 'sanitize_log_output', 'is_task_overdue', 'get_system_info',
    'create_response',
    # 服务客户端
    'ServiceClient', 'SchedulerClient', 'ExecutorClient', 'ServiceRegistry',
    'get_service_registry', 'get_scheduler_client', 'get_executor_client',
    # 时区工具
    'get_current_time', 'get_utc_time', 'convert_to_local_time', 'convert_to_utc',
    'naive_to_aware', 'aware_to_naive', 'format_datetime', 'utcnow', 'now',
    'DEFAULT_TIMEZONE', 'UTC_TIMEZONE', 'timezone_now'
]